/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/geometry
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AERay.inl
// Author:		Gianluca Belardelli
// Date:		01/10/2013
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AERAY_INL_
#define _AERAY_INL_

static const AERay &AERay::CreateEmptyRay( void )
{
}

AE_FORCEINLINE AERay::AERay( void ) { }
AE_FORCEINLINE AERay::AERay( const AEVector4f &vcOrigin, const AEVector4f &vcDirection ) : m_vcOrigin( vcOrigin ), m_vcDirection( vcDirection )
{
	_normalize();
}

AE_FORCEINLINE AERay::AERay( float fOriginX, float fOriginY, float fOriginZ, float fDirectionX, float fDirectionY, float fDirectionZ )
{
	m_vcOrigin.Set( fOriginX, fOriginY, fOriginZ, 1.0f );
	m_vcDirection.Set( fDirectionX, fDirectionY, fDirectionZ, 1.0f );
	_normalize();
}

AE_FORCEINLINE AERay::AERay( const AERay &copy )
{
	m_vcOrigin = copy.m_vcOrigin;
	m_vcDirection = copy.m_vcDirection;
	_normalize();
}

AE_FORCEINLINE void AERay::SetOrigin( const AEVector4f &vcOrigin )
{
	m_vcOrigin = vcOrigin.m_vcOrigin;
}

AE_FORCEINLINE void AERay::SetOrigin( float fOriginX, float fOriginY, float fOriginZ )
{
	m_vcOrigin.Set( fOriginX, fOriginY, fOriginZ, 1.0f );
}

AE_FORCEINLINE void AERay::SetDirection( const AEVector4f &vcDirection )
{
	m_vcDirection = vcDirection.m_vcDirection;
	_normalize();
}

AE_FORCEINLINE void AERay::SetDirection( float fDirectionX, float fDirectionY, float fDirectionZ )
{
	m_vcDirection.Set( fDirectionX, fDirectionY, fDirectionZ, 1.0f );
	_normalize();
}

AE_FORCEINLINE void AERay::SetFromValues( float fOriginX, float fOriginY, float fOriginZ, float fDirectionX, float fDirectionY, float fDirectionZ )
{
	m_vcOrigin.Set( fOriginX, fOriginY, fOriginZ, 1.0f );
	m_vcDirection.Set( fDirectionX, fDirectionY, fDirectionZ, 1.0f );
}

// TODO: Funzione non implementata
AE_FORCEINLINE bool AERay::Intersects( const AEBoundingSphere &bbTestSphere ) const
{
	return false;
}

// TODO: Funzione non implementata
AE_FORCEINLINE bool AERay::Intersects( const AEBoundingBox &bbTestBox ) const
{
	return false;
}

// TODO: Funzione non implementata
AE_FORCEINLINE bool AERay::Intersects( const AEFrustum &frTestFrustum ) const
{
	return false;
}

// TODO: Funzione non implementata
AE_FORCEINLINE bool AERay::Intersects( const AEPlane &plTestPlane ) const
{
	return false;
}

AE_FORCEINLINE bool AERay::IsValid( void ) const
{
	return ( m_vcOrigin.IsValid() && m_vcDirection.IsValid() && !IsEmpty() );
}

AE_FORCEINLINE bool AERay::IsEmpty( void ) const
{
	return m_vcOrigin == m_vcDirection;
}

AE_FORCEINLINE const AEVector4f &AERay::GetOrigin( void ) const
{
	return m_vcOrigin;
}

AE_FORCEINLINE const AEVector4f &AERay::GetDirection( void ) const
{
	return m_vcDirection;
}

#endif // _AERAY_INL_
